This folder is made available as part of the following research paper to be published in Sensors.

Title: Illuminating the Neural Landscape of Pilot Mental States: A Convolutional Neural Network Approach with Shapley Additive Explanations Interpretability
Authors: Ibrahim M. Alreshidi, Desmond B. Bisandu, and Irene Moulitsas.
Citation: Alreshidi, I.; Bisandu, D.; Moulitsas, I. Illuminating the Neural Landscape of Pilot Mental States: A Convolutional Neural Network Approach with Shapley Additive Explanations Interpretability. Sensors 2023, 23, 9052. https://doi.org/10.3390/s23229052

Abtract:
Predicting pilots' mental states is a critical challenge in aviation safety and performance, with electroencephalogram data offering a promising avenue for detection. However, the interpreta-bility of machine learning and deep learning models, which are often used for such tasks, re-mains a significant issue. This study aims to address these challenges by developing an inter-pretable model to detect four mental states—channelized attention, diverted attention, star-tle/surprise, and normal state in pilots using EEG data. The methodology involves training a convolutional neural network on power spectral density features of EEG data from 17 pilots. The model's interpretability is enhanced through the use of SHapley Additive exPlanations values, which identify the top 10 most influential features for each mental state. The results demonstrate high performance in all metrics, with an average accuracy of 96%, a precision of 96%, recall of 94%, and an F1-score of 95%. An examination of the effects of mental states on EEG frequency bands further elucidates the neural mechanisms underlying these states. The innovative nature of this study lies in its combination of high-performance model development, improved inter-pretability, and in-depth analysis of the neural correlates of mental states. This approach not only addresses the critical need for effective and interpretable mental state detection in aviation, but also contributes to our understanding of the neural underpinnings of these states. This study thus represents a significant advancement in the field of EEG-based mental state detection.

We have performed our experiments on an Intel(R) Core(TM) i7-10700 2.90 GHz CPU with 32 GBytes RAM PC. We have used Python within Jupyter Notebook to write the code for our experiments. Utilised libraires include Scikit-Learn, SHAP, MNE (version 1.2), and Tensorflow (version 2.4)

## Contents of this repository
Data: 
This folder contains:
- PSD (Power Spectral Density) features and labels datasets for individual pilots. These were leveraged to acquire the results presented in Table 2 of our article. For results pertaining to a specific pilot, two files are utilised to train our proposed model: "Pilot_i_EEG_band_power_features.npy" and "Pilot_i_events.npy". In these filenames, 'i' represents the pilot's unique ID number. The file "Pilot_i_EEG_band_power_features.npy" contains power spectral density features extracted from five distinct frequency bands: delta, theta, alpha, beta, and gamma. On the other hand, "Pilot_i_events.npy" contains the class labels indicating the mental state of the pilot: 0 for baseline, 1 for startle/surprise, 2 for channelized attention, and 3 for diverted attention.
- A combined dataset named "EEG_band_power_features.npy", which comprises the PSD features for all pilots. Its corresponding class labels are found in the "all_events.npy" file. This combined dataset was instrumental in deriving the results published in our paper.

Source code:
This folder contains:
- A jupyter notebook called EEG_Stats.ipynb which computes the PSD features using the original EEG data for each pilot. It also include the source code to compute the average power in each frequency band for each mental state and the average power in each frequency band for each EEG channel using the combined pilots dataset.
- A jupyter notebook called Ind_pilot_conv_model.ipynb which implements the proposed 1D-CNN approach presented and tested in the journal paper for each pilot.
- A jupyter notebook called all_pilots.ipynb which implements the proposed 1D-CNN approach presented and tested in the journal paper for all pilots. It also includes the source code to obtain the training accuracy and loss curves, compute the confusion matrix, and obtain the top 10 important features for each mental state.

Output:
This folder contains:
- A figure called "The average power in each frequency band across pilots" which shows the average power in each frequency band for each mental state using the combined pilots dataset.
- A figure called "Heatmap for the average power in each frequency band for EEG channels" which shows the average power in each frequency band for each EEG channel using the combined pilots dataset.
- A figure called "Confusion Matrix" which shows the confusion matrix results of the proposed 1D-CNN model using the combined pilots dataset.
- A figure called "Accuracy and loss curve" which shows the training accuracy and loss curves results of the proposed 1D-CNN model using the combined pilots dataset.
- A figure called "Top 10 important features for NE class" which shows the top 10 important features for detecting the baseline state using the combined pilots dataset.
- A figure called "Top 10 important features for SS class" which shows the top 10 important features for detecting the Startle/Surprise state using the combined pilots dataset.
- A figure called "Top 10 important features for CA class" which shows the top 10 important features for detecting the Channelised Attention state using the combined pilots dataset.
- A figure called "Top 10 important features for DA class" which shows the top 10 important features for detecting the Diverted Attention state using the combined pilots dataset.
- A text file called "1D-CNN model evaluation" which contain the results produced by all the proposed 1D-CNN model presented and tested in the journal paper.
